#!/usr/local/bin/python3.6
# coding:utf-8
# @Time    : 2019/11/1 16:36
# @Author  : ZhangBing
# @Email   : 18829272841@163.com
# @File    : demo1.py
# @Software: PyCharm
import openpyxl
import random

wb = openpyxl.load_workbook('demo.xlsx')

sh1 = wb.active
sh1.title = '测试程序'
sh1['A1'] = 'key'
sh1['B1'] = 'value'
for i in range(2, 11):
    sh1['A{}'.format(i)] = i
    sh1['B{}'.format(i)] = random.randint(1, 1000)
wb.save('demo.xlsx')
for row in sh1.rows:
    if row[0].coordinate != 'A1':
        print(row[0].value, row[1].value)

del wb

if __name__ == "__main__":
    pass
